<?php

namespace App\Models\Kms\Task;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;

class TaskTemplateNodesModel extends BaseModel
{
    use HasFactory;

    protected $table = "kms_task_template_nodes";

    protected $fillable = [
        "templateId",
        "step",
        "preStep",
        "businessType",
        "businessTypeText",
        "handleType",
        "approveType",
        "createdAt",
        "createdByUid",
        "updatedAt",
        "updatedByUid",
        "businessStatusEnum",
        "rejectBusinessStatusEnum"
    ];

    const BUSINESS_TYPE_INVALID  = 0;
    const BUSINESS_TYPE_GENERATE = 1;
    const BUSINESS_TYPE_SUBMIT   = 2;
    const BUSINESS_TYPE_APPROVE  = 3;
    const BUSINESS_TYPE_FINISHED = 100;
    const BUSINESS_TYPE_TEXT     = [
        self::BUSINESS_TYPE_INVALID  => "任务作废节点",
        self::BUSINESS_TYPE_GENERATE => "任务生成节点",
        self::BUSINESS_TYPE_SUBMIT   => "表单提交节点",
        self::BUSINESS_TYPE_APPROVE  => "审批人审批节点",
        self::BUSINESS_TYPE_FINISHED => "任务流程结束节点",
    ];

    const APPROVAL_TYPE_DEFAULT  = 0;//默认不处理
    const APPROVAL_TYPE_STOP     = 1;//驳回直接终止
    const APPROVAL_TYPE_PRE_NODE = 2;//驳回回滚到上一节点

    /**
     * @return HasMany
     */
    public function nodesProcessorRel(): HasMany
    {
        return $this->hasMany(TaskTemplateNodesProcessorModel::class, "nodeId", "id");
    }
}
